/**
 * bilibili 状态管理
 */
import { create } from 'zustand'
import { persist } from 'zustand/middleware'

/**
 * bilibili cookie
 * cookie: bilibili cookie
 * setBlCookie: 设置 bilibili cookie
 * resetBlCookie: 重置 bilibili cookie
 */
// const useBlCookie = create((set): any => ({
//   blCookie: '',
//   setBlCookie: (blCookie = '') => {
//     set({ blCookie })
//   },
//   resetBlCookie: () => set({ blCookie: '' }),
// }))

/**
 * 持久化存储 bilibili cookie
 * blCookie: bilibili cookie
 * setBlCookie: 设置 bilibili cookie
 * resetBlCookie: 重置 bilibili cookie
 */
const useBlCookie = create(persist(
  (set): any => ({
    blCookie: '',
    setBlCookie: (blCookie = '') => {
      set({ blCookie })
    },
    resetBlCookie: () => set({ blCookie: '' }),
  }),
  {
    name: 'blCookie',
    // getStorage: () => sessionStorage, // 默认
  }
))


export {
  useBlCookie,
}
